package com.heima.behavior.controller.v1;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.behavior.LikesBehaviorDto;
import com.heima.model.behavior.ReadBehaviorDto;
import com.heima.model.behavior.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lzq
 * @data 2023/5/10 14:13
 */
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 用户点赞
     */
    @PostMapping("/likes_behavior")
    public ResponseResult  likesBehavior(@RequestBody LikesBehaviorDto dto ){
       return behaviorService.likesBehavior(dto);
    }

    /**
     * 阅读量统计
     * @param dto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto dto){
       return  behaviorService.readBehavior(dto);
    }

    /**
     * 喜欢,不喜欢
     * @param dto
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDto dto){
        return  behaviorService.unLikesBehavior(dto);
    }
}
